﻿function Account()
{
	this.Owner = "";
	this.Created = new Date();
	this.Transactions = [];
	this.Cash = function ()
	{
		var sum = 0;
		for (var t in this.Transactions)
		{
			sum += t.Amount;
		}
		return sum;
	}
	this.Comment = "";

	this.AddTransaction = function (amount, date, comment)
	{
		var trans = new Tranction();
		trans.Account = this;
		if (amount != undefined)
		{
			trans.Amount = amount;
		}
		if (date != undefined)
		{
			trans.Date = date;
		}
		if (comment != undefined)
		{
			trans.Comment = comment;
		}
		this.Transactions.push(trans);

		return trans;
	};
}

function Transaction()
{
	this.Account = null;
	this.Amount = 0;
	this.Date = new Date();
	this.Comment = "";
}